class cached_property(object):
    """此装饰器类似property，不过所装饰的属性带有缓存，属性代码只执行一回"""

    def __init__(self, func):
        self.func = func
        self.__doc__ = getattr(func, "__doc__")
        self.name = func.__name__

    def __get__(self, instance, cls=None):
        if instance is None:
            return self
        res = instance.__dict__[self.name] = self.func(instance)
        return res
